#!/usr/bin/env python

import gtk
import gtksourceview2

class Window(gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)

        self.buffer = gtksourceview2.Buffer()
        self.manager = gtksourceview2.LanguageManager()

        self.language = self.manager.get_language("c")

        self.buffer.set_language(self.language)
        self.buffer.set_highlight_syntax(True)

        self.view = gtksourceview2.View(self.buffer)
        self.view.set_show_line_numbers(True)
        self.view.set_auto_indent(True)
        self.view.set_insert_spaces_instead_of_tabs(True)
        self.view.set_smart_home_end(gtksourceview2.SMART_HOME_END_AFTER)

        self.view.set_tab_width(4)

        self.view.set_left_margin(7);
        self.view.set_right_margin(7);

        self.resize(800, 400)
        self.add(self.view)

        self.connect('destroy', gtk.main_quit)

        self.show_all()

        print("languages: ", self.manager.get_language_ids())

    def main(self):
        gtk.main()

if __name__ == '__main__':
    w = Window()
    w.main()
